using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ACME.Northwind.DataTransfer;

namespace ACME.Northwind.Service.Interfaces
{
	/// <summary>
	/// The service interface for all Data Transfer Objects (DTO)
	/// </summary>
	/// <typeparam name="T"></typeparam>
	public partial interface IService<T> where T : IDTO
	{
		/// <summary>
		/// Return a list of all item of the specified type
		/// </summary>
		List<T> RunSelect();
		/// <summary>
		/// Return a paginated list of items based on a LINQ criteria
		/// </summary>
		/// <returns></returns>
		PagedQueryResults<T> RunSelect(int pageIndex, int pageSize, bool ascending, string sortColumn, string linq);
		/// <summary>
		/// Return a list of items based on a LINQ criteria
		/// </summary>
		/// <param name="linq"></param>
		/// <returns></returns>
		List<T> RunSelect(string linq);
	}

	/// <summary>
	/// The service interface for all persistable Data Transfer Objects (DTO)
	/// </summary>
	/// <typeparam name="T"></typeparam>
	public partial interface IPersistableService<T> where T : IDTO
	{
		/// <summary>
		/// Return a list of all item of the specified type
		/// </summary>
		List<T> RunSelect();
		/// <summary>
		/// Return a paginated list of items based on a LINQ criteria
		/// </summary>
		/// <param name="pageIndex">The page offset to load</param>
		/// <param name="pageSize">The number of records per page</param>
		/// <param name="ascending">Determines the sort direction</param>
		/// <param name="sortColumn">Determines the column on which to sort</param>
		/// <param name="linq">The LINQ query used for selection</param>
		/// <returns></returns>
		PagedQueryResults<T> RunSelect(int pageIndex, int pageSize, bool ascending, string sortColumn, string linq);
		/// <summary>
		/// Return a list of items based on a LINQ criteria
		/// </summary>
		/// <param name="linq">The LINQ query used for selection</param>
		/// <returns></returns>
		List<T> RunSelect(string linq);
		/// <summary>
		/// Saves the specific DTO to store
		/// </summary>
		/// <param name="dto">The DTO item to persist</param>
		bool Persist(T dto);
		/// <summary>
		/// Persist a DTO list to store
		/// </summary>
		/// <param name="list">The DTO list to persist</param>
		bool Persist(List<T> list);
		/// <summary>
		/// Delete a single item
		/// </summary>
		/// <param name="item">The DTO item to delete</param>
		bool Delete(T item);
	}
}
